<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/res/back/css/base.css" rel="stylesheet" type="text/css" />
<link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/res/third/bootstrap3/jsone/bootstrap.min.js" type="text/javascript"></script>
<script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
<script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
<script src="/res/third/layer/layer.js"></script>
<script type="text/javascript">
	function sosuo(){
		var lpath =location.pathname;
		//var pageNo = $("#pageNo").val();
		$("#soform").attr("action",lpath+"?pageNo="+1);
		$("#soform").submit();
	}

	$(document).ready(function(){
		
		 
	})
</script>
<style type="text/css">
	table{table-layout: fixed;}
	td{overflow: hidden;text-overflow:ellipsis;}
	.excelbtn{display: inline-block;height: 100%;width: 100px;background-color:#38A4C7;color: #fff;text-align: center;line-height: 35px;cursor: pointer;border-radius:5px;}
</style>
</head>

<body>
	<div class="panel panel-info panel-content">
	<div class="panel-heading" style="position: relative;">
			<button style="float: right" type="button" onclick="addrule()" class="btn btn-info">
				<span class="glyphicon glyphicon-plus"></span>
				&nbsp;新增规则
			</button>
			<form id="soform" method="post">
				<table>
					<tr>
						<td class="w80" style="padding-top: 5px">
							<label for="companyname" class="center-block">规则标题：</label>
						</td>
						<td class="w150 ">
							<input type="text" class="form-control" name="so_title" value="${so_title!}" id="so_search" placeholder="规则标题" data-options="">
						</td>
						<td class="w80" style="padding-top: 5px;">
							<label for="so_status" class="center-block">状态：</label>
						</td>
						<td class="w120 ">
							<select class="form-control" name="so_status">
							    <option value="1" [#if !so_status?? || so_status == '' || so_status == '1']selected="selected"[/#if]>可用规则</option>
								<option value="2" [#if so_status?? && so_status=='2']selected="selected"[/#if]>不可用规则</option>
							</select>
						</td>
						<td style="padding-left: 10px">
							<div class="input-group">
								<span class="input-group-btn" style="border: 1px solid #ddd;">
									<button class="btn btn-default" type="button" onclick="sosuo()">搜索</button>
								</span>
							</div>
						</td>
					</tr>
				</table>
		</form>
		</div>
		<table class="table table-hover table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th width="8%">序号</th>
					<th width="12%">规则名称</th>
					<th width="10%">生效时间</th>
					<th width="10%">失效时间</th>
					<th width="10%">规则标识</th>
					<!--  
					<th width="10%">对应企业类型</th>
					-->
					<th width="10%">规则类型</th>
					<th width="10%">数量</th>
                    <th width="10%">比例</th>
					<th width="20%">操作</th>
				</tr>
			</thead>
			[#list pagination.list as rule]
			<tr>
				<td align="center">${rule_index+1!}</td>
				<td align="center">${rule.title!}</td>
				<td align="center">${(rule.starttime?string("yyyy-MM-dd"))!}</td>
				<td align="center">${(rule.endtime?string("yyyy-MM-dd"))!}</td>
				<td align="center">${rule.ruleCode!}</td>
				
				<td align="center">
					[#if rule.operateType==1]赠送[/#if]
					[#if rule.operateType==-1]抵扣[/#if]
				</td>
				<td align="center">
					${rule.amount!}
				</td>
				<td align="center">
					[#if (rule.coinAmount)?? && (rule.orderAmount)??]
						${rule.coinAmount!}/${rule.orderAmount!}
					[/#if]
				</td>
				<td align="center">
				  <button type="button" class="btn btn-info btn-xs delbtn" onclick="coinruleEdit('${rule.ruleCode!}')">编辑</button> 
				  <button type="button" class="btn btn-info btn-xs delbtn" onclick="doremoved('${rule.id!}')">[#if rule.removed==0]禁用[#else]恢复使用[/#if]</button>
				</td>
			</tr>
			[/#list]
		</table>

		<div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
		 
	</div>
</body>
</html>
<script type="text/javascript">

function addrule(){
	top.addTempTab("/coin/coinruleAdd.do");
}
function coinruleEdit(ruleCode){
	top.addTempTab("/coin/coinruleEdit.do?ruleCode="+ruleCode);
}
function coinRecord(){
	top.addTempTab("/coin/coinRecord_list.do");
}
 
function doremoved(id){
	art.dialog.post({
		  
		type : "post",
		dataType : "json",
		url : "/coin/remove_coin.do",
		data : {id:id},
		success : function(data) {
			 if(data.success){
				 alert(data.msg);
				 location.reload();
			 }else{
				 alert(data.msg);
			 }
		}
 
	},"数据正在提交.... ");
}
</script>